package com.xnyzc.lhy.common.penum.order;

public enum EInvoiceStatus {

    defaultValue(0, "默认值"),
    waitInvitation(1, "待邀约"),
    hasInvitation(2, "已邀约"),
    beInvitationPersonAgrees(3, "被邀约人同意"),
    beInvitationPersonRefuse(4, "被邀约人拒绝"),
    invitationPersonCancel(5, "邀约人取消"),
    beInvitationPersonCancel(6, "被邀约人取消"),
    systemTimeOutCancel(7, "系统超时取消");

    private Integer value;
    private String desc;

    EInvoiceStatus(Integer value, String desc) {
        this.desc = desc;
        this.value = value;
    }

    /**
     * 判断是否存在邀约订单
     *
     * @return
     */
    public static boolean isPresenceOrder(Integer status) {
        EInvoiceStatus byType = findByType(status);
        switch (byType) {
            case hasInvitation:
            case beInvitationPersonAgrees:
                return true;
        }
        return false;
    }

    public static EInvoiceStatus findByType(Integer type) {
        switch (type) {
            case 1:
                return waitInvitation;
            case 2:
                return hasInvitation;
            case 3:
                return beInvitationPersonAgrees;
            case 4:
                return beInvitationPersonRefuse;
            case 5:
                return invitationPersonCancel;
            case 6:
                return beInvitationPersonCancel;
            case 7:
                return systemTimeOutCancel;
        }
        return defaultValue;
    }

    public Integer getValue() {
        return value;
    }
}
